<div class="admin-content">

  <div class="am-cf am-padding">
    <div class="am-fl am-cf"> <strong class="am-text-primary am-text-lg">文档管理</strong>
      /
      <small>OfficeWord</small>
    </div>
  </div>
  
  <div class="am-g">
    <div class="am-u-md-6 am-cf">
      <div class="am-fl am-cf">
        <div class="am-btn-toolbar am-fl">
          <div class="am-btn-group am-btn-group-xs">
            <button type="button" class="am-btn am-btn-default" onclick="location.href='<?=site_url('word/create')?>'">
              <span class="am-icon-plus"></span>
              新增
            </button>
            <button type="button" class="am-btn am-btn-default">
              <span class="am-icon-trash-o"></span>
              删除
            </button>
          </div>

        </div>
      </div>
    </div>
    <div class="am-u-md-3 am-cf">
      <div class="am-fr">
        <div class="am-input-group am-input-group-sm">
          <input type="text" class="am-form-field">
          <span class="am-input-group-btn">
            <button class="am-btn am-btn-default" type="button">搜索</button>
          </span>
        </div>
      </div>
    </div>
  </div>

  <div class="am-g">
    <div class="am-u-sm-12">
        <table class="am-table am-table-striped am-table-hover table-main">
          <thead>
            <tr>
              <th class="table-id">ID</th>
              <th class="table-title">文档标题</th>
              <th class="table-type">操作</th>
              <th class="table-author">发表时间</th>
              <th class="table-set">操作</th>
            </tr>
          </thead>
          <tbody>
            <?php foreach($list as $k => $v):?>

            <tr>
              <td><?=$v['id']?></td>
              <td><?=$v['title']?></td>
              <td><?=$v['user_id']?></td>
              <td><?=date('Y年m月d日 H:i:s',$v['create_time'])?></td>
              <td>
                <div class="am-btn-toolbar">
                  <div class="am-btn-group am-btn-group-xs">
                    <?php if($v['status'] == 1):?>
                    <button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="set_status('<?=$v['id']?>')">
                      <span class="am-icon-pencil-square-o"></span>
                      已读
                    </button>
                    <?php endif;?>
                    <button class="am-btn am-btn-default am-btn-xs am-text-danger" onclick="del_news('<?=$v['id']?>')">
                      <span class="am-icon-trash-o"></span>
                      删除
                    </button>
                  </div>
                </div>
              </td>
            </tr>
            <?php endforeach;?>
          </tbody>
        </table>
        <div id="msg">
        </div>
        <div class="am-cf">
          共 <?=$rows?> 条记录
          <div class="am-fr">
            <ul class="am-pagination"><?=$page?></ul>
          </div>
        </div>
        <hr />
        <p>注：.....</p>
    </div>

  </div>
</div>

<script type="text/javascript">
  function set_status(nid){
    $.get("<?=site_url('news/set_status')?>",{id:nid},function(res){

      if(res == 1){
        location.reload();
      }else{
        var data = '<div class="am-alert am-alert-danger" onclick="msg_close()"><span class="am-icon-close am-icon-sm">  '+res+'</span><br/></div>';
        set_msg(data);
      }
    })
  }

  function del_news(nid){
    $.post("<?=site_url('news/del_news')?>",{nid:nid},function(res){

      if(res == 1){
        location.reload();
      }else{
        var data = '<div class="am-alert am-alert-danger" onclick="msg_close()"><span class="am-icon-close am-icon-sm">  '+res+'</span><br/></div>';
        set_msg(data);
      }
    })
  }
</script>